package com.txm.qqserver.service;

import com.txm.qqcommon.Response;

import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

public abstract class Server {

    private static ServerSocket serverSocket = null;

    private static ManageClientThreads MCTC = null;
    private static Socket accept = null;
    private static Response res = null;

    public Server() {
        try {
            System.out.println("服务器已启动在：http://" + InetAddress.getLocalHost().getHostAddress() + ":9000");
            if (serverSocket == null)
                serverSocket = new ServerSocket(9000);
            if (MCTC == null)
                MCTC = new ManageClientThreads();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public ServerSocket getServerSocket() {
        return serverSocket;
    }

    public ManageClientThreads getMCTC() {
        return MCTC;
    }

    public Socket getAccept() {
        return accept;
    }

    public static void setAccept(Socket accept) {
        Server.accept = accept;
    }

    public Response getRes() {
        return res;
    }

    public void setRes(Response res) {
        Server.res = res;
    }

    public abstract void method(String path, Object obj);

}
